  	
		/* JAVASCRIPT TAE KWON DO GAME/TRAINING AID (C) MERLYN-ELECTRONICS | DAVID PALMER March 2011 | All Rights Reserved*/

		var theGame;

		function init() {
			document.getElementById('TKDGameDiv').innerHTML = ''; 
			theGame = null; 
			theGame = new TKDGame('TKDGameDiv');
		}

		function onresize() {
			init();
		}

		function TKDGame(aLocationId) { 
			this.FLocation = document.getElementById(aLocationId);
			this.FLocation.innerHTML = '';
			this.FDifficulty = 0;
			this.FShuffledQuestions = new Array;
			this.FCurrentQuestion = 0;
			this.FTotalQuestions = 0;
			this.FIncorrectAnswers = new Array;
			this.FQuestionBuffer = null;

			var self = this;
		
			this.FLocation.style.height = '400px';
			this.FBeltColors = new Array('#FFFFFF', '#FFFF00', '#00FF00', '#0000FF', '#FF0000', '#000000');
			this.FBelts = new Array();
			for (i = 0; i < 10; i++){
				var beltColor = this.FBeltColors[Math.floor(i/2)]
				var stripeColor = null;
				if (i % 2 == 1) stripeColor = this.FBeltColors[Math.floor(i/2) + 1];
				this.FBelts[i] = new Belt(i, this, (25 * i) + 36, 30, beltColor, stripeColor); 
			}
			this.FBelts[0].MoveBelt(36, 50)

			this.FBelts[0].AddQuestion('What is the Korean for "Middle Section Block"?', 'Kaunde Makgi');
			this.FBelts[0].AddQuestion('What is the Korean for "Low Section Block"?', 'Najunde Makgi');
			this.FBelts[0].AddQuestion('What is the Korean for "Inner Forearm"?', 'An Palmok');
			this.FBelts[0].AddQuestion('What is the Korean for "Outer Forearm"?', 'Bakat Palmok');
			this.FBelts[0].AddQuestion('What is the Korean for "Forefist"?', 'Ap Joomuk');
			this.FBelts[0].AddQuestion('What is the Korean for "High"?', 'Nopunde');
			this.FBelts[0].AddQuestion('What is the Korean for "Middle"?', 'Kaunde');
			this.FBelts[0].AddQuestion('What is the Korean for "Low"?', 'Najunde');
			this.FBelts[0].AddQuestion('What is the Korean for "Front Kick"?', 'Ap Chagi');
			this.FBelts[0].AddQuestion('What is the Korean for "Front Rising kick"?', 'Ap Chaolligi');
			this.FBelts[0].AddQuestion('What is the Korean for "One"?', 'Hanna');
			this.FBelts[0].AddQuestion('What is the Korean for "Two"?', 'Dool');
			this.FBelts[0].AddQuestion('What is the Korean for "Three"?', 'Seth');
			this.FBelts[0].AddQuestion('What is the Korean for "Four"?', 'Neth');
			this.FBelts[0].AddQuestion('What is the Korean for "Five"?', 'Dasaul');
			this.FBelts[0].AddQuestion('What is the Korean for "Six"?', 'Yosaul');
			this.FBelts[0].AddQuestion('What is the Korean for "Seven"?', 'Ilgop');
			this.FBelts[0].AddQuestion('What is the Korean for "Eight"?', 'Yodoll');
			this.FBelts[0].AddQuestion('What is the Korean for "Nine"?', 'Ahop');
			this.FBelts[0].AddQuestion('What is the Korean for "Ten"?', 'Yoll');
			this.FBelts[0].AddQuestion('What is the Korean for "Instructor"?', 'Sabum');
			this.FBelts[0].AddQuestion('What is the Korean for "Student"?', 'Jeja');
			this.FBelts[0].AddQuestion('What is the Korean for "Training Hall"?', 'Dojang');
			this.FBelts[0].AddQuestion('What is the Korean for "Belt"?', 'Ti');
			this.FBelts[0].AddQuestion('What is the Korean for "Press Ups"?', 'Momtong Bachia');
			this.FBelts[0].AddQuestion('What is the Korean for "Inwards"?', 'Anaero');
			this.FBelts[0].AddQuestion('What is the Korean for "Outwards"?', 'Bakaero');
			this.FBelts[0].AddQuestion('What is the Korean for "Training Suit"?', 'Dobok');
			this.FBelts[0].AddQuestion('What is the Korean for "Start"?', 'Si Jak');
			this.FBelts[0].AddQuestion('What is the Korean for "Stop"?', 'Goman');
			this.FBelts[0].AddQuestion('What is the Korean for "Return To Ready Stance"?', 'Barrol');
			this.FBelts[0].AddQuestion('What is the Korean for "Bow"?', 'Kyong Ye');
			this.FBelts[0].AddQuestion('What is the Korean for "Obverse Punch"?', 'Baro Jirugi');
			this.FBelts[0].AddQuestion('What is the Korean for "Reverse Punch"?', 'Bandae Jirugi');
			this.FBelts[0].AddQuestion('What is the Korean for "Attention Stance"?', 'Charyot Sogi');
			this.FBelts[0].AddQuestion('What is the Korean for "Sitting Stance"?', 'Annun Sogi'); 
			this.FBelts[0].AddQuestion('What is the Korean for "Walking Stance"?', 'Gunnun Sogi'); 
			this.FBelts[0].AddQuestion('What is the Korean for "Parallel Ready Stance"?', 'Narani Chunbi Sogi');

			this.FBelts[1].AddQuestion('How would you interpret "Chon Ji"?', 'Chon Ji literally means the heaven and the earth, in the orient it is the creation of the world or the beginning of human history, therefore it is the initial patterns played by the beginner.  It consists of two similar parts, one to represent the heaven and the other the earth.');
			this.FBelts[1].AddQuestion('How many moves are there in "Chon Ji"?', '19');
			this.FBelts[1].AddQuestion('What is the Korean for "Rising Block"?', 'Chookyo Makgi'); 
			this.FBelts[1].AddQuestion('What is the Korean for "Guarding Block"?', 'Daebi Makgi');
			this.FBelts[1].AddQuestion('What is the Korean for "Ball of the foot"?', 'Ap Kumchi');
			this.FBelts[1].AddQuestion('What is the Korean for "Head"?', 'Mori');
			this.FBelts[1].AddQuestion('What is the Korean for "L-Stance"?', 'Niunja Sogi');
			this.FBelts[1].AddQuestion('What is the Korean for "Knife-hand Strike"?', 'Sonkal Taerigi');
			this.FBelts[1].AddQuestion('What is the Korean for "Front Snap Kick"?', 'Ap cha Busigi');
			this.FBelts[1].AddQuestion('What is the Korean for "Left"?', 'Wen');
			this.FBelts[1].AddQuestion('What is the Korean for "Right"?', 'Orun');
			this.FBelts[1].AddQuestion('What is the Korean for "Pattern"?', 'Tul');
			this.FBelts[1].AddQuestion('What is the Korean for "Kick"?', 'Chagi');

			this.FBelts[2].AddQuestion('How would you interpret "Dan Gun"?', 'Dan Gun is named after the Holy Dan Gun. The legendary founder of Korea in the year 2333BC');
			this.FBelts[2].AddQuestion('How many moves are there in "Dan Gun"?', '21');
			this.FBelts[2].AddQuestion('What is the Korean for "Twin Forearm Block"?', 'Sang Palmok Makgi');
			this.FBelts[2].AddQuestion('What is the Korean for "Turning Kick"?', 'Dollyo Chagi');
			this.FBelts[2].AddQuestion('What is the Korean for "Backfist Front Strike"?', 'Dung Joomuk Ap Taerigi');
			this.FBelts[2].AddQuestion('What is the Korean for "3 Step Sparring"?', 'Sambo Matsoki');
			this.FBelts[2].AddQuestion('What is the Korean for "Knife Hand Guarding Block"?', 'Sonkal Daebi Makgi');
			this.FBelts[2].AddQuestion('What is the Korean for "Inwards Outer Forearm Block"?', 'Anaero Bakat Palmok Makgi');
			this.FBelts[2].AddQuestion('What is the Korean for "Backfist"?', 'Dung Joomuk');

			this.FBelts[3].AddQuestion('How would you interpret the pattern "Do San"?', 'Do San is the pseudonym of the patriot An Ch\'ang ho 1876-1938. Who devoted his life to furthering the education of Korea and its independent movement.');
			this.FBelts[3].AddQuestion('How many moves are there in "Do San"?', '24');
			this.FBelts[3].AddQuestion('What is the Korean for "Foot sword"?', 'Balkal');
			this.FBelts[3].AddQuestion('What is the Korean for "Wrist Release"?', 'Jappyo Sol Tae');
			this.FBelts[3].AddQuestion('What is the Korean for "Wedging Block"?', 'Hechyo Makgi');
			this.FBelts[3].AddQuestion('What is the Korean for "Straight Fingertip Thrust"?', 'Son Sonkut Tulgi');
			this.FBelts[3].AddQuestion('What is the Korean for "Side Kick"?', 'Yop Chagi');
			this.FBelts[3].AddQuestion('What is the Korean for "Backfist Side Strike"?', 'Dung Joomuk Yop Taerigi');
			this.FBelts[3].AddQuestion('What is the Korean for "Fingertips"?', 'Sonkut');
			this.FBelts[3].AddQuestion('What is the Korean for "Straight"?', 'Son');
			this.FBelts[3].AddQuestion('What is the Korean for "Thrust"?', 'Tulgi');
			this.FBelts[3].AddQuestion('What is the Korean for "Hook Punch"?', 'Golcho Jirugi');

			this.FBelts[4].AddQuestion('How would you interpret the pattern "Won Hyo"?', 'Won Hyo was the noted monk who introduced Buddhism to the Silla Dynasty in 686AD.');
			this.FBelts[4].AddQuestion('How many moves are there in "Won Hyo"?', '28');
			this.FBelts[4].AddQuestion('What is the Korean for "Back Sole"?', 'Dwit Kumchi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Back Heel"?', 'Dwit Chook'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Circular Block"?', 'Dollimyo Makgi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Waist Block"?', 'Hori Makgi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Side Punch"?', 'Yop Jirugi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Back Kick"?', 'Dwit Chagi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Close Ready Stance"?', 'Moa Chunbi Sogi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Bending Ready Stance"?', 'Goburyo Sogi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Vertical Stance"?', 'Soojik Sogi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Fixed Stance"?', 'Gojong Sogi'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Semi Free Sparring"?', 'Ban Jayoo Matsoki'); 
			this.FBelts[4].AddQuestion('What is the Korean for "Foot Parts"?', 'Habansin');
			this.FBelts[4].AddQuestion('What is the Korean for "Hand Parts"?', 'Sangbansin');
			this.FBelts[4].AddQuestion('What is the Korean for "Palm"?', 'Sonbadak');
			this.FBelts[4].AddQuestion('What is the Korean for "Reverse Side Kick"?', 'Bandae Yop Chagi');
			this.FBelts[4].AddQuestion('What is the Korean for "Reverse Knife Hand Strike"?', 'Dung Sonkal Taerigi');
			this.FBelts[4].AddQuestion('What is the Korean for "Consecutive Kick"?', 'Yonsok Chagi');
			this.FBelts[4].AddQuestion('What is the Korean for "Back"?', 'Dwit');
			this.FBelts[4].AddQuestion('What is the Korean for "Downwards"?', 'Naeryo');
			this.FBelts[4].AddQuestion('What is the Korean for "At Ease"?', 'Swiyo');

			this.FBelts[5].AddQuestion('How would you interpret "Yul Gok"?', 'Yul Gok is the pseudonym of the patriot Yi Il 1536-1584 who was nicknamed the Confucius of Korea, the 38 moves refer to his birthplace on 38 latitude and the diagram represents the scholar.');
			this.FBelts[5].AddQuestion('How many moves are there in "Yul Gok"?', '38');
			this.FBelts[5].AddQuestion('What is the Korean for "Jumping"?', 'Twigi');
			this.FBelts[5].AddQuestion('What is the Korean for "Double Forearm Block"?', 'Doo Palmok Makgi'); 
			this.FBelts[5].AddQuestion('What is the Korean for "Hooking Block"?', 'Golcho Makgi');
			this.FBelts[5].AddQuestion('What is the Korean for "Twin Knife-hand Block"?', 'Sang Sonkal Makgi');
			this.FBelts[5].AddQuestion('What is the Korean for "Palm Upward Block"?', 'Sonbadak Ollyo Makgi');
			this.FBelts[5].AddQuestion('What is the Korean for "X-fist Pressing Block"?', 'Kyocha Joomuk Noollo Makgi');
			this.FBelts[5].AddQuestion('What is the Korean for "Palm Pushing Block"?', 'Sonbadak Miro Makgi');
			this.FBelts[5].AddQuestion('What is the Korean for "Front Elbow Strike"?', 'Ap Palkup Taerigi');
			this.FBelts[5].AddQuestion('What is the Korean for "Twin  Vertical Punch"?', 'Sang  Sewo Jirugi');
			this.FBelts[5].AddQuestion('What is the Korean for "Knee  Kick"?', 'Moorup Chagi');
			this.FBelts[5].AddQuestion('What is the Korean for "Twin  Upset Punch"?', 'Sang  Dwijibo Jirugi');
			this.FBelts[5].AddQuestion('What is the Korean for "Flat Fingertip Thrust"?', 'Opun Sonkut Tulgi');
			this.FBelts[5].AddQuestion('What is the Korean for "Reverse Turning Kick"?', 'Bandae Dollyo Chagi');
			this.FBelts[5].AddQuestion('What is the Korean for "Knee"?', 'Moorup');
			this.FBelts[5].AddQuestion('What is the Korean for "Elbow"?', 'Palkup');
			this.FBelts[5].AddQuestion('What is the Korean for "Grasp"?', 'Butjaba');
			this.FBelts[5].AddQuestion('What is the Korean for "Knife Hand Rising Block"?', 'Sonkal Chookyo Makgi');
			this.FBelts[5].AddQuestion('What is the Korean for "Back Elbow Strike"?', 'Dwit Palkup Taerigi');
			this.FBelts[5].AddQuestion('What is the Korean for "2 Step Sparring"?', 'Ibo Matsoki');
			this.FBelts[5].AddQuestion('What is the Korean for "Free Sparring"?', 'Jayoo Matsoki');
			this.FBelts[5].AddQuestion('What is the Korean for "X-Stance"?', 'Kyocha Sogi');

			this.FBelts[6].AddQuestion('How would you interpret the pattern "Joon Gun"?', 'Joon Gun is named after the patriot An Joon Gun, who assassinated Hiro Bumi Ito the Japanese Governor General of Korea. The man who was said to have played the leading part in the Korea Japan merger. The 32 moves refer to his age when he was executed in the Lui Shung prison in 1910.');
			this.FBelts[6].AddQuestion('How many moves are there in "Joon Gun"?', '32');
			this.FBelts[6].AddQuestion('What is the Korean for "Rear Foot Stance"?', 'Dwit Bal Sogi');
			this.FBelts[6].AddQuestion('What is the Korean for "Low Stance"?', 'Nachuo Sogi');
			this.FBelts[6].AddQuestion('What is the Korean for "Palm Pressing Block"?', 'Sonbadak Noollo Makgi');
			this.FBelts[6].AddQuestion('What is the Korean for "U-Shape block"?', 'Digutcha Makgi');
			this.FBelts[6].AddQuestion('What is the Korean for "Twin Straight Forearm Block"?', 'Sang Sun Palmok Makgi');
			this.FBelts[6].AddQuestion('What is the Korean for "Upper Elbow Strike"?', 'Wi Palkup Taerigi');
			this.FBelts[6].AddQuestion('What is the Korean for "Palm Heel Strike"?', 'Sonbadak Taerigi');
			this.FBelts[6].AddQuestion('What is the Korean for "Arc Hand Strike"?', 'Bandalson Taerigi');
			this.FBelts[6].AddQuestion('What is the Korean for "Side-fist Strike"?', 'Yop Joomuk Taerigi');
			this.FBelts[6].AddQuestion('What is the Korean for "Hooking Kick"?', 'Golcho Chagi');
			this.FBelts[6].AddQuestion('What is the Korean for "Side Sole"?', 'Yop Bal Badak');
			this.FBelts[6].AddQuestion('What is the Korean for "Back Of The Forearm"?', 'Dung Palmok');
			this.FBelts[6].AddQuestion('What is the Korean for "Arc Hand"?', 'Bandalson');
			this.FBelts[6].AddQuestion('What is the Korean for "Upwards Palm Block"?', 'Ollyo Sonbadak Makgi');
			this.FBelts[6].AddQuestion('What is the Korean for "Stick Block"?', 'Mong Dungi Makgi');
			this.FBelts[6].AddQuestion('What is the Korean for "Reverse Knife Hand Block"?', 'Dung Sonkal Makgi');
			this.FBelts[6].AddQuestion('What is the Korean for "Turning Punch"?', 'Dollyo Jirugi');
			this.FBelts[6].AddQuestion('What is the Korean for "Downwards (Axe) Kick"?', 'Naeryo Chagi');
			this.FBelts[6].AddQuestion('What is the Korean for "Crescent Kick"?', 'Bandal Chagi');
			this.FBelts[6].AddQuestion('What is the Korean for "Front Pushing Kick"?', 'Ap Cha Milgi');

			this.FBelts[7].AddQuestion('How would you interpret the pattern "Toi Gye"?', 'Toi Gye is the pen name of the philosopher and scholar Yi Hwang 16AD, who was an authority on neo confucianism. The 37 moves relate to his birthplace on 37 latitude and the diagram represents the scholar.');
			this.FBelts[7].AddQuestion('How many moves are there in "Toi Gye"?', '37');
			this.FBelts[7].AddQuestion('What is the Korean for "Upset Fingertip Thrust"?', 'Dwijibun Sonkut Tulgi');
			this.FBelts[7].AddQuestion('What is the Korean for "W Shape Block"?', 'San Makgi');
			this.FBelts[7].AddQuestion('What is the Korean for "Flying Kick"?', 'Twimyo Chagi');
			this.FBelts[7].AddQuestion('What is the Korean for "1 Step Sparring"?', 'Ilbo Matsoki');
			this.FBelts[7].AddQuestion('What is the Korean for "Flying"?', 'Twimyo');

			this.FBelts[8].AddQuestion('How would you interpret the pattern "Hwa Rang"?', 'Hwa Rang is named after the Hwa Rang youth group, which originated in the Silla dynasty around 600AD. This group eventually became the driving force behind the unification of the three kingdoms of Korea. The 29 moves refer to the 29th infantry division in which Tae Kwon Do developed into maturity.');
			this.FBelts[8].AddQuestion('How many moves are there in "Hwa Rang"?', '29');
			this.FBelts[8].AddQuestion('What is the Korean for "Instep"?', 'Baldung'); 
			this.FBelts[8].AddQuestion('What is the Korean for "Reverse Foot Sword"?', 'Balkal Dung'); 
			this.FBelts[8].AddQuestion('What is the Korean for "Upwards Punch"?', 'Ollyo Jirugi'); 
			this.FBelts[8].AddQuestion('What is the Korean for "Downwards Knife Hand Strike"?', 'Naeryo Sonkal Taerigi'); 
			this.FBelts[8].AddQuestion('What is the Korean for "Flying High Kick"?', 'Twimyo Nopi Chagi'); 
			this.FBelts[9].AddQuestion('How would you interpret the pattern "Choong Moo"?', 'Choong Moo was the given name to the Admiral Yi Sun of the Yi Dynasty 1592. He was reputed to have invented the first armoured battleship (Kobukson) which was the precursor to the modern day submarine. The reason why the pattern ends with a left hand attack is to symbolise his regrettable death having no chance to show his unrestrained potentiality checked by his forced reservation of his loyalty to the King.');
			this.FBelts[9].AddQuestion('How many moves are there in "Choong Moo"?', '30');	
			this.FBelts[9].AddQuestion('What is the Korean for "Finger"?', 'Songarak');
			this.FBelts[9].AddQuestion('What is the Korean for "Checking Block"?', 'Momchau Makgi');
			this.FBelts[9].AddQuestion('What is the Korean for "Side Piercing Kick"?', 'Yop Cha Jirugi'); 
			this.FBelts[9].AddQuestion('What is the Korean for "Side Rising Kick"?', 'Yop Chaollogi');
			this.FBelts[9].AddQuestion('What is the Korean for "Double Upwards Palm Block"?', 'Doo Sonbadak Ollyo Makgi');
			this.FBelts[9].AddQuestion('What is the Korean for "Twisting Kick"?', 'Bituro Chagi');
			this.FBelts[9].AddQuestion('What is the Korean for "Dismiss"?', 'Haessan');
			this.FBelts[9].AddQuestion('What is the Korean for "Forwards"?', 'Appro Kaggi');
			this.FBelts[9].AddQuestion('What is the Korean for "Backwards"?', 'Dwiyro Kaggi');
			this.FBelts[9].AddQuestion('What is the Korean for "About Turn"?', 'Dwiyro Torro');

			this.FBeltSlider = new Slider(this, 31, 30, 253);
			this.FBeltSlider.SetPosition(14); 
			this.FBeltSlider.SetText('Click on a belt to set difficulty.');

			this.SetBelts = function SetBelts(aBelt) {
				for (i = 0; i < 10; i++){
					if (i == aBelt) this.FBelts[i].MoveBelt((25 * i) + 36, 50);
					else this.FBelts[i].MoveBelt((25 * i) + 36, 30);
				}
				this.FBeltSlider.SetPosition((25 * aBelt) + 14);
				this.FDifficulty = aBelt; 
				this.SetQuestions(aBelt);
			}

			this.FQuestionSlider = new Slider(this, 345, 30, 253);

			this.FQuestionBox = new QABox(this, 31, 150, 565, 150);
			this.FAnswerBox = new QABox(this, 31, 205, 565, 150);
			this.FResultsBox = new QABox(this, 31, 350, 565, 150);

			this.FAnswerBox.SetTitle('CLICK TO REVEAL ANSWER.');
			this.FAnswerBox.FTitleDiv.style.cursor = 'Pointer';
			this.FAnswerBox.FTitleDiv.onclick = function() {
				self.FAnswerBox.FContentDiv.style.display = 'Block';
				self.FCorrectButton.FDomObj.style.display = 'Block';
				self.FIncorrectButton.FDomObj.style.display = 'Block';
				
			}
			this.FCorrectButton = new TKDButton(this, 202, 318, 'Correct');
			this.FCorrectButton.FDomObj.onclick = function() {
				self.NextQuestion();
			}
			this.FIncorrectButton = new TKDButton(this, 320, 318, 'Incorrect');
			this.FIncorrectButton.FDomObj.onclick = function() {
				self.FIncorrectAnswers[self.FIncorrectAnswers.length] = self.FQuestionBuffer;
				self.NextQuestion();
			}
			
			this.NextQuestion = function NextQuestion() {
				if (self.FCurrentQuestion < self.FTotalQuestions) {
					self.FCurrentQuestion = self.FCurrentQuestion + 1;
					self.DrawQuestions(self.FShuffledQuestions.pop());			
				}
				else {
					self.FCurrentQuestion = self.FCurrentQuestion + 1;
					self.DisplayResults();
				}
			}
			
		        this.FDisplayButton = new TKDButton(this, 488, 386, 'Display Results'); 
			this.FDisplayButton.FDomObj.onclick = function () {
				self.DisplayResults();			
			}
			
			this.DisplayResults = function DisplayResults() {
				
				var currentScore = eval(this.FCurrentQuestion - this.FIncorrectAnswers.length - 1) + ' out of ' + eval(this.FCurrentQuestion - 1) + ' questions answered correctly.'; 

				this.FLocation.innerHTML = '';
				this.FLocation.style.height = '';
				
				var title = document.createElement('h2');
				title.innerHTML = 'Results - ' + currentScore;
				this.FLocation.appendChild(title);
				
				var tryAgain = new TKDButton(this, 500, 13, 'Try Again');
				tryAgain.FDomObj.onclick = function () {
					init();
				}
				
				if (this.FIncorrectAnswers.length > 0) {
				
					var text = document.createElement('p');
					text.innerHTML = 'You marked yourself as incorrect on the following questions:';
					this.FLocation.appendChild(text);
				
					var table, body, row, headCell, dataCell;
					table = document.createElement('table');
					self.FLocation.appendChild(table);
					for (i = 0; i < self.FIncorrectAnswers.length; i++) {
						row = document.createElement('tr');
						table.appendChild(row);
						
						cell = document.createElement('td');
						cell.style.width = '300px';
						cell.innerHTML = this.FIncorrectAnswers[i].Question;
						row.appendChild(cell);
						
						cell = document.createElement('td');
						cell.style.width = '300px';
						cell.innerHTML = this.FIncorrectAnswers[i].Answer;
						row.appendChild(cell);
					}
				}
				else {
					if (this.FCurrentQuestion != 1) {	
						var text = document.createElement('p');
						text.innerHTML = 'Well done! You marked yourself correct for all questions!!';
						this.FLocation.appendChild(text);			
					}	
				}
			}
			
			
			this.FStartOver = new TKDButton(this, 31, 386, 'Start Over'); 
			this.FStartOver.FDomObj.onclick = function () {
				self.SetQuestions(self.FDifficulty);
			}

			this.SetQuestions = function SetQuestions(aBelt) {
				var questionsPool = new Array();
				for (i = aBelt; i >= 0; i--) {
					for (j = 0; j < this.FBelts[i].FQuestions.length; j++) questionsPool[questionsPool.length] = this.FBelts[i].FQuestions[j]; 
				}
				this.FShuffledQuestions = shuffle(questionsPool);
				this.FCurrentQuestion = 1;
				this.FTotalQuestions = this.FShuffledQuestions.length;
				this.FIncorrectAnswers = new Array;

				this.DrawQuestions(this.FShuffledQuestions.pop())
			}

			this.DrawQuestions = function DrawQuestions(aQuestion) {

				this.FQuestionBuffer = aQuestion;
			
				this.FQuestionSlider.SetPosition(Math.floor((this.FCurrentQuestion - 1) / (this.FTotalQuestions - 1) * 225) + 14);
				
				var beltName = '';
				switch (this.FDifficulty) {
					case 0: beltName = 'White belt'; break;
					case 1: beltName = 'Yellow tag'; break;
					case 2: beltName = 'Yellow belt'; break;
					case 3: beltName = 'Green tag'; break;
					case 4: beltName = 'Green belt'; break;
					case 5: beltName = 'Blue tag'; break;
					case 6: beltName = 'Blue belt'; break;
					case 7: beltName = 'Red tag'; break;
					case 8: beltName = 'Red belt'; break;
					case 9: beltName = 'Black tag'; break;
				}
				
				
				this.FQuestionSlider.SetText(beltName + '. Question ' + this.FCurrentQuestion + ' of ' + this.FTotalQuestions + '.'); 

				this.FQuestionBox.SetTitle('Question ' + this.FCurrentQuestion + '.');
				this.FQuestionBox.SetContent(aQuestion.Question);

              			this.FAnswerBox.FContentDiv.style.display = 'None';
  				self.FCorrectButton.FDomObj.style.display = 'None';
				self.FIncorrectButton.FDomObj.style.display = 'None';
				this.FAnswerBox.SetContent(aQuestion.Answer);	
				

				if (this.FCurrentQuestion != 1)
					this.FResultsBox.SetTitle(eval(this.FCurrentQuestion - this.FIncorrectAnswers.length - 1) + ' out of ' + eval(this.FCurrentQuestion-1) + ' questions answered correctly.')
				else 
					this.FResultsBox.SetTitle('No questions have been marked yet.');		  
			}

			this.SetQuestions(this.FDifficulty); 
		}

		function Belt(aIndex, aOwner, aXPos, aYPos, aBeltColor, aStripeColor) {
			this.FIndex = aIndex;
			this.FOwner = aOwner;
			this.FX = aXPos + getXPosition(this.FOwner.FLocation);
			this.FY = aYPos + getYPosition(this.FOwner.FLocation);
			this.FQuestions = new Array();

			this.FBeltBase = document.createElement('div');
			this.FBeltBase.style.position = 'Absolute';
			this.FBeltBase.style.left = this.FX + 'px';
			this.FBeltBase.style.top = this.FY + 'px';
			this.FBeltBase.style.width = '16px';
			this.FBeltBase.style.height = '70px';
			this.FBeltBase.style.borderLeft = '1px solid #000000';
			this.FBeltBase.style.borderRight = '1px solid #000000';
			this.FBeltBase.style.borderBottom = '1px solid #000000';
			this.FBeltBase.style.cursor = 'Pointer';
			this.FBeltBase.style.backgroundColor = aBeltColor;
			this.FOwner.FLocation.appendChild(this.FBeltBase);

			var self = this;
			this.FBeltBase.onclick = function() {
				self.FOwner.SetBelts(self.FIndex);
			}

			if (aStripeColor != null) {
				this.FBeltStripe = document.createElement('div');
				this.FBeltStripe.style.position = 'Absolute';
				this.FBeltStripe.style.left = '0px';
				this.FBeltStripe.style.top ='50px';
				this.FBeltStripe.style.width = '16px';
				this.FBeltStripe.style.height = '8px';
				this.FBeltStripe.style.borderTop = '1px solid #000000';
				this.FBeltStripe.style.borderBottom = '1px solid #000000';
				this.FBeltStripe.style.backgroundColor = aStripeColor;
				this.FBeltBase.appendChild(this.FBeltStripe);
			}

			this.AddQuestion = function AddQuestion(aQuestion, aAnswer) {
				this.FQuestions[this.FQuestions.length] = new Question(aQuestion, aAnswer);   
			}

			this.MoveBelt = function MoveBelt(aXPos, aYPos) {
				this.FX = aXPos + getXPosition(this.FOwner.FLocation);
				this.FY = aYPos + getYPosition(this.FOwner.FLocation);
				this.FBeltBase.style.left = this.FX + 'px';
				this.FBeltBase.style.top = this.FY + 'px';
			}       
		}

		function Slider(aOwner, aXPos, aYPos, aLength) {
			this.FOwner = aOwner;
			this.FX = aXPos + getXPosition(this.FOwner.FLocation);
			this.FY = aYPos + getYPosition(this.FOwner.FLocation);
			this.FLength = aLength;			              

			this.FColor = '#AAAAAA';	

			this.FDomObj = document.createElement('div'); 
			this.FDomObj.style.position = 'Absolute'
			this.FDomObj.style.left = this.FX + 'px';
			this.FDomObj.style.top = this.FY + 'px';
			this.FDomObj.style.width = this.FLength + 'px';
			this.FDomObj.style.height = '22px';
			this.FDomObj.style.backgroundColor = '#FFFFFF';
			this.FOwner.FLocation.appendChild(this.FDomObj);

			this.FText = document.createElement('div');
			this.FText.style.textAlign = 'Center';
			this.FText.style.color = '#000000';
			this.FText.style.fontWeight = 'Bold';
			this.FText.innerHTML = ' ';
			this.FDomObj.appendChild(this.FText);

			this.FLine = document.createElement('div');
			this.FLine.style.position = 'Absolute';
			this.FLine.style.left = '0px';
			this.FLine.style.top = '22px';
			this.FLine.style.width = this.FLength + 'px';
			this.FLine.style.height = '4px';
			this.FLine.style.backgroundColor = this.FColor;
			this.FDomObj.appendChild(this.FLine);

			this.FPointer = document.createElement('div');
			this.FPointer.style.position = 'Absolute';
			this.FPointer.style.left = '-3px';
			this.FPointer.style.top = '17px';
			this.FPointer.style.width = '7px';
			this.FPointer.style.height = '7px';

			var lines = new Array();
			for (i = 0; i < 4; i++) {
				lines[i] = document.createElement('div');
				lines[i].style.width = (7 - (i * 2)) + 'px';
				lines[i].style.height = '1px';
				lines[i].style.position = 'Absolute';
				lines[i].style.top = i + 'px';
				lines[i].style.left = i + 'px';
				lines[i].style.backgroundColor = this.FColor;
				this.FPointer.appendChild(lines[i]);
			}

			this.FDomObj.appendChild(this.FPointer);

			this.SetPosition = function SetPosition(aPosition) {
				this.FPosition = aPosition;
				this.FPointer.style.left = (aPosition - 3) + 'px';
			}

                     		this.SetText = function SetText(aText) {
				this.FText.innerHTML = aText;
			}	
		}

		function QABox(aOwner, aXPos, aYPos, aWidth, aHeight) {
			this.FOwner = aOwner;
			this.FX = aXPos + getXPosition(this.FOwner.FLocation);
			this.FY = aYPos + getYPosition(this.FOwner.FLocation);
			this.FWidth = aWidth;			                
			this.FHeight = aHeight;

			this.FDomObj = document.createElement('div'); 
			this.FDomObj.style.position = 'Absolute'
			this.FDomObj.style.left = this.FX + 'px';
			this.FDomObj.style.top = this.FY + 'px';
			this.FDomObj.style.width = this.FWidth + 'px';
			this.FDomObj.style.height = this.FHeight + 'px';
			this.FOwner.FLocation.appendChild(this.FDomObj);

			this.FTitleDiv = document.createElement('div');
			this.FTitleDiv.style.textAlign = 'Center';
			this.FTitleDiv.style.color = '#000000';
			this.FTitleDiv.style.fontWeight = 'Bold';
			this.FTitleDiv.style.borderBottom = '4px solid #AAAAAA';
			this.FDomObj.appendChild(this.FTitleDiv);

			this.FContentDiv = document.createElement('div');
			this.FContentDiv.style.textAlign = 'Center';
			this.FContentDiv.style.color = '#000000';
			this.FContentDiv.style.fontWeight = 'Bold';
			this.FDomObj.appendChild(this.FContentDiv);

			this.SetTitle = function SetTitle(aText) {
				this.FTitleDiv.innerHTML = aText
			}

			this.SetContent = function SetContent(aText) {
				this.FContentDiv.innerHTML = aText;
			}
		}

		function TKDButton(aOwner, aXPos, aYPos, aLabel) {
			this.FOwner = aOwner;
			this.FX = aXPos + getXPosition(this.FOwner.FLocation);
			this.FY = aYPos + getYPosition(this.FOwner.FLocation);

			this.FDomObj = document.createElement('div'); 
			this.FDomObj.style.position = 'Absolute'
			this.FDomObj.style.left = this.FX + 'px';
			this.FDomObj.style.top = this.FY + 'px';
			this.FDomObj.style.width = '100px';
			this.FDomObj.style.height = '20px';
			this.FDomObj.style.border = '4px solid #AAAAAA';
			this.FDomObj.style.textAlign = 'Center';
			this.FDomObj.style.color = '#000000';
			this.FDomObj.style.fontWeight = 'Bold';
			this.FDomObj.style.cursor = 'Pointer';
			this.FDomObj.innerHTML = aLabel;
			this.FOwner.FLocation.appendChild(this.FDomObj);
		}


		function Question(aQuestion, aAnswer) {
			this.Question = aQuestion;
			this.Answer = aAnswer;			
		}


		function getXPosition(obj){
			var XValue = 0;
			while(obj){
				XValue+= obj.offsetLeft;
				obj= obj.offsetParent;
			}
			return XValue;
		}

		function getYPosition(obj){
			var YValue = 0;
			while(obj){
				YValue+= obj.offsetTop;
				obj= obj.offsetParent;
			}
			return YValue;
		}

		function trim(stringToTrim) {
			return stringToTrim.replace(/^\s+|\s+$/g,"");
		}

		function shuffle (aArray) { 
			for(var j, x, i = aArray.length; i; j = parseInt(Math.random() * i), 
			buffer = aArray[--i], aArray[i] = aArray[j], aArray[j] = buffer);
			return aArray;
		}


